package com.group10.mapper;

import com.group10.entity.Show;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import java.util.ArrayList;

@Component
public interface ShowMapper {

    @Select("select *from shows")
    ArrayList<Show> getAllShow();

    @Select("select *from shows where id=#{id}")
    Show getShowById(Integer id);

    @Select("select *from shows where classify=#{classify}")
    ArrayList<Show> getShowByClassify(String classify);

    @Insert("insert into shows(detail,url,classify) values(#{detail},#{url},#{classify})")
    int insertShow(String detail,String url,String classify);

    @Delete("delete from shows where id=#{id}")
    int deleteShow(Integer id);

    @Update("update shows set like_count=like_count+1 where id=#{id}")
    int likeShow(Integer id);

    @Update("update shows set like_count=like_count-1 where id=#{id}")
    int unLikeShow(Integer id);

    @Update("update shows set collect=collect+1 where id=#{id}")
    int collectShow();
}
